<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="公司代码" prop="gcdm">
        <el-input
          v-model="queryParams.gcdm"
          placeholder="请输入公司代码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="维修用时" prop="wxys">
        <el-input
          v-model="queryParams.wxys"
          placeholder="请输入维修用时"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="维修费用" prop="wxfy">
        <el-input
          v-model="queryParams.wxfy"
          placeholder="请输入维修费用"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否停机" prop="sftj">
        <el-input
          v-model="queryParams.sftj"
          placeholder="请输入是否停机"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="停机时长" prop="tjsz">
        <el-input
          v-model="queryParams.tjsz"
          placeholder="请输入停机时长"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否更换配件" prop="sfghpj">
        <el-input
          v-model="queryParams.sfghpj"
          placeholder="请输入是否更换配件"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工作描述" prop="gzms">
        <el-input
          v-model="queryParams.gzms"
          placeholder="请输入工作描述"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="维修图片" prop="wxtp">
        <el-input
          v-model="queryParams.wxtp"
          placeholder="请输入维修图片"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="维修班组" prop="wxbz">
        <el-input
          v-model="queryParams.wxbz"
          placeholder="请输入维修班组"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="维修状态" prop="wxzt">
        <el-input
          v-model="queryParams.wxzt"
          placeholder="请输入维修状态"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备部位" prop="sbbw">
        <el-input
          v-model="queryParams.sbbw"
          placeholder="请输入设备部位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公司名称" prop="gcmc">
        <el-input
          v-model="queryParams.gcmc"
          placeholder="请输入公司名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="故障原因" prop="gzyy">
        <el-input
          v-model="queryParams.gzyy"
          placeholder="请输入故障原因"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="故障类别" prop="gzlb">
        <el-input
          v-model="queryParams.gzlb"
          placeholder="请输入故障类别"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="维修级别" prop="wxjb">
        <el-input
          v-model="queryParams.wxjb"
          placeholder="请输入维修级别"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="维修类别" prop="wxlb">
        <el-input
          v-model="queryParams.wxlb"
          placeholder="请输入维修类别"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="主修人" prop="zxr">
        <el-input
          v-model="queryParams.zxr"
          placeholder="请输入主修人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="辅助维修人" prop="fzwxr">
        <el-input
          v-model="queryParams.fzwxr"
          placeholder="请输入辅助维修人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="维修单号" prop="wxdh">
        <el-input
          v-model="queryParams.wxdh"
          placeholder="请输入维修单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="报修单号" prop="bxdh">
        <el-input
          v-model="queryParams.bxdh"
          placeholder="请输入报修单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备编码" prop="sbbm">
        <el-input
          v-model="queryParams.sbbm"
          placeholder="请输入设备编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="处理进度" prop="cljd">
        <el-input
          v-model="queryParams.cljd"
          placeholder="请输入处理进度"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备名称" prop="sbmc">
        <el-input
          v-model="queryParams.sbmc"
          placeholder="请输入设备名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开始时间" prop="kssj">
        <el-date-picker clearable
          v-model="queryParams.kssj"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择开始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="结束时间" prop="jssj">
        <el-date-picker clearable
          v-model="queryParams.jssj"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择结束时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['device:gzwx:add']"
        >快速维修单</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['device:gzwx:edit']"
        >编辑维修单</el-button>
      </el-col>
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="danger"-->
<!--          plain-->
<!--          icon="el-icon-delete"-->
<!--          size="mini"-->
<!--          :disabled="multiple"-->
<!--          @click="handleDelete"-->
<!--          v-hasPermi="['device:gzwx:remove']"-->
<!--        >删除</el-button>-->
<!--      </el-col>-->

      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-s-custom"
          size="mini"
          @click="handleJobSub"
          :disabled="single"
          v-hasPermi="['device:gzwx:jobSub']"
        >变更维修员</el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-document-delete"
          size="mini"
          :disabled="single"
          @click="handleCancelReport"
          v-hasPermi="['device:gzwx:cancelReport']"
        >撤 单</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-message-solid"
          size="mini"
          @click="handleCheck"
          :disabled="single"
          v-hasPermi="['device:gzwx:check']"
        >验证详情</el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['device:gzwx:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading"  :data="gzwxList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="维修单号" align="center" prop="wxdh" />
      <el-table-column label="设备名称" align="center" prop="sbmc" />
      <el-table-column label="处理进度" align="center" prop="cljd">
        <template slot-scope="scope">
          <!--   <el-badge :value="1" :max="1" :hidden="isHidden" :type="badgeType"  class="item">
             </el-badge>-->
          <dict-tag :options="dict.type.device_fault_progress" :value="scope.row.cljd"/>
        </template>
      </el-table-column>
      <el-table-column label="故障确认" align="center" prop="gzqr">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.device_is_confirm" :value="scope.row.gzqr"/>
        </template>
      </el-table-column>
      <el-table-column label="故障确认图片" align="center" prop="gzqrtp" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.gzqrtp || ''" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="故障确认时间" align="center" prop="gzqrsj" width="150">
        <!-- <template slot-scope="scope">
           <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>
         </template>-->
      </el-table-column>
      <el-table-column label="开始时间" align="center" prop="kssj" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.kssj, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="结束时间" align="center" prop="jssj" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.jssj, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="维修费用" align="center" prop="wxfy" />
      <el-table-column label="是否停机" align="center" prop="sftj" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.device_is_shut_down" :value="scope.row.sftj"/>
        </template>
      </el-table-column>
      <el-table-column label="停机时长" align="center" prop="tjsz" />
      <el-table-column label="是否更换配件" align="center" prop="sfghpj">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.device_is_ghpj" :value="scope.row.sfghpj"/>
        </template>
      </el-table-column>
      <el-table-column label="工作描述" show-overflow-tooltip align="center" prop="gzms" />
      <el-table-column label="维修图片" align="center" prop="wxtp" >
        <template slot-scope="scope">
          <image-preview :src="scope.row.wxtp || ''" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="维修班组" align="center" prop="wxbz"  :formatter="postFormat"/>
      <el-table-column label="维修状态" align="center" prop="wxzt">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.device_repair_state" :value="scope.row.wxzt"/>
        </template>
      </el-table-column>
      <el-table-column label="设备部位" align="center" prop="sbbw" />
      <el-table-column label="故障类别" align="center" prop="gzlb" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.device_fault_type" :value="scope.row.gzlb"/>
        </template>
      </el-table-column>
      <el-table-column label="维修级别" align="center" prop="wxjb">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.device_repair_level" :value="scope.row.wxjb"/>
        </template>
      </el-table-column>
      <el-table-column label="维修类别" align="center" prop="wxlb">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.device_repair_type" :value="scope.row.wxlb"/>
        </template>
      </el-table-column>
      <el-table-column label="主修人" align="center" prop="zxr" />
      <el-table-column label="辅助维修人" align="center" prop="fzwxr" />
      <el-table-column label="报修单号" align="center" prop="bxdh" width="150" show-overflow-tooltip />



      <el-table-column label="主键" align="center" prop="id" />
      <el-table-column label="公司代码" align="center" prop="gcdm" />
      <el-table-column label="维修用时" align="center" prop="wxys" />
      <el-table-column label="公司名称" align="center" prop="gcmc" />
      <el-table-column label="故障原因" align="center" prop="gzyy" />
      <el-table-column label="设备编码" align="center" prop="sbbm" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['device:gzwx:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['device:gzwx:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改设备故障维修对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="维修单号" prop="wxdh">
          <el-input v-model="form.wxdh" placeholder="请输入维修单号" />
        </el-form-item>
        <el-form-item label="报修单号" prop="bxdh">
          <el-input v-model="form.bxdh" placeholder="请输入报修单号" />
        </el-form-item>
        <el-form-item label="维修费用" prop="wxfy">
          <el-input v-model="form.wxfy" placeholder="请输入维修费用" />
        </el-form-item>
        <el-form-item label="工作描述" prop="gzms">
          <el-input v-model="form.gzms" placeholder="请输入工作描述" type="textarea"/>
        </el-form-item>
        <el-form-item label="维修状态" prop="wxzt">
          <el-select v-model="form.wxzt" placeholder="请选择维修状态">
            <el-option
              v-for="dict in dict.type.device_repair_state"
              :key="dict.value"
              :label="dict.label" :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="设备部位" prop="sbbw">
          <el-input v-model="form.sbbw" placeholder="请输入设备部位" />
        </el-form-item>
        <el-form-item label="故障原因" prop="gzyy">
          <el-select v-model="form.gzyy" placeholder="请选择故障原因">
            <el-option
              v-for="dict in dict.type.device_failure_cause"
              :key="dict.value"
              :label="dict.label" :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="故障类别" prop="gzlb">
          <el-select v-model="form.gzlb" placeholder="请选择故障类别">
            <el-option
              v-for="dict in dict.type.device_fault_type"
              :key="dict.value"
              :label="dict.label" :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="维修级别" prop="wxjb">
          <el-select v-model="form.wxjb" placeholder="请选择维修级别">
            <el-option
              v-for="dict in dict.type.device_repair_level"
              :key="dict.value"
              :label="dict.label" :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="维修类别" prop="wxlb">
          <el-select v-model="form.wxlb" placeholder="请选择维修类别">
            <el-option
              v-for="dict in dict.type.device_repair_type"
              :key="dict.value"
              :label="dict.label" :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>




        <el-form-item label="公司代码" prop="gcdm">
          <el-input v-model="form.gcdm" placeholder="请输入公司代码" />
        </el-form-item>
        <el-form-item label="维修用时" prop="wxys">
          <el-input v-model="form.wxys" placeholder="请输入维修用时" />
        </el-form-item>
        <el-form-item label="是否停机" prop="sftj">
          <el-input v-model="form.sftj" placeholder="请输入是否停机" />
        </el-form-item>
        <el-form-item label="停机时长" prop="tjsz">
          <el-input v-model="form.tjsz" placeholder="请输入停机时长" />
        </el-form-item>
        <el-form-item label="是否更换配件" prop="sfghpj">
          <el-input v-model="form.sfghpj" placeholder="请输入是否更换配件" />
        </el-form-item>
        <el-form-item label="维修图片" prop="wxtp">
          <el-input v-model="form.wxtp" placeholder="请输入维修图片" />
        </el-form-item>
        <el-form-item label="维修班组" prop="wxbz">
          <el-input v-model="form.wxbz" placeholder="请输入维修班组" />
        </el-form-item>
        <el-form-item label="公司名称" prop="gcmc">
          <el-input v-model="form.gcmc" placeholder="请输入公司名称" />
        </el-form-item>
        <el-form-item label="主修人" prop="zxr">
          <el-input v-model="form.zxr" placeholder="请输入主修人" />
        </el-form-item>
        <el-form-item label="辅助维修人" prop="fzwxr">
          <el-input v-model="form.fzwxr" placeholder="请输入辅助维修人" />
        </el-form-item>
        <el-form-item label="设备编码" prop="sbbm">
          <el-input v-model="form.sbbm" placeholder="请输入设备编码" />
        </el-form-item>
        <el-form-item label="处理进度" prop="cljd">
          <el-input v-model="form.cljd" placeholder="请输入处理进度" />
        </el-form-item>
        <el-form-item label="设备名称" prop="sbmc">
          <el-input v-model="form.sbmc" placeholder="请输入设备名称" />
        </el-form-item>
        <el-form-item label="开始时间" prop="kssj">
          <el-date-picker clearable
            v-model="form.kssj"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择开始时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="结束时间" prop="jssj">
          <el-date-picker clearable
            v-model="form.jssj"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择结束时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!--变更维修员-->
    <el-dialog :title="jobSub.title" :visible.sync="jobSub.open" width="1000px" append-to-body>
      <div id="userPost">
        <!-- 注册名 -->
        <userPost ref="userPost"></userPost>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="handleClick">更 改</el-button>
        <el-button @click="jobSub.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <!--验证详情-->
    <el-dialog :title="check.title" :visible.sync="check.open" width="400px" append-to-body>
      <el-form ref="checkForm"  :model="checkForm" label-width="80px">
        <el-form-item label="操作人" prop="remark">
          <span>{{checkForm.createBy}}</span>
        </el-form-item>
        <el-form-item label="验证状态"   prop="isFinish">
          <span :style="color">{{checkForm.isFinish}}</span>
        </el-form-item>
        <el-form-item label="维修评分"  v-show="isWc" prop="repairScore">
          <span>{{checkForm.repairScore}}</span>
        </el-form-item>
        <el-form-item label="评价" v-show="isWc" prop="remark">
          <span>{{checkForm.remark}}</span>
        </el-form-item>
        <el-form-item label="驳回原因" v-show="isBh"  prop="remark">
          <span>{{checkForm.remark}}</span>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="check.open =false">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listGzwx,
  getGzwx,
  delGzwx,
  addGzwx,
  updateGzwx,
  cancelDeviceFailureReport,
  updateJobSub, cancelDeviceFailureRepair
} from "@/api/device/gzwx";
import userPost from '@/views/system/user/userPost'
import { getDeviceFailureCheckByReportId} from "@/api/device/gcyz";

export default {
  name: "Gzwx",
  // 注册组件
  components: {
    userPost
  },
  dicts: ['device_repair_state','device_fault_progress','device_repair_type', 'device_is_ghpj', 'device_fault_type', 'device_repair_level', 'device_is_shut_down', 'device_failure_cause','device_is_confirm'],
  data() {
    return {
      //完成
      isWc:true,
      //驳回
      isBh:true,
      color:'color:green',
      checkForm:{},
      /*验证详情*/
      check:{
        // 是否显示弹出层（
        open: false,
        // 弹出层标题
        title: "",
      },
      /*派工界面*/
      jobSub:{
        // 是否显示弹出层（
        open: false,
        // 弹出层标题
        title: "",
      },
      cancelReport:{
        // 是否显示弹出层（
        open: false,
        // 弹出层标题
        title: "",
        remark:""
      },
      postOptions:[],
      reportIds: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 设备故障维修表格数据
      gzwxList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        gcdm: null,
        wxys: null,
        wxfy: null,
        sftj: null,
        tjsz: null,
        sfghpj: null,
        gzms: null,
        wxtp: null,
        wxbz: null,
        wxzt: null,
        sbbw: null,
        gcmc: null,
        gzyy: null,
        gzlb: null,
        wxjb: null,
        wxlb: null,
        zxr: null,
        fzwxr: null,
        wxdh: null,
        bxdh: null,
        sbbm: null,
        cljd: null,
        sbmc: null,
        kssj: null,
        jssj: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {

    /** 查询设备故障维修列表 */
    getList() {
      this.loading = true;
      listGzwx(this.queryParams).then(response => {
        this.gzwxList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        xh: null,
        gcdm: null,
        wxys: null,
        wxfy: null,
        sftj: null,
        tjsz: null,
        sfghpj: null,
        gzms: null,
        wxtp: null,
        wxbz: null,
        wxzt: null,
        sbbw: null,
        gcmc: null,
        gzyy: null,
        gzlb: null,
        wxjb: null,
        wxlb: null,
        zxr: null,
        fzwxr: null,
        wxdh: null,
        bxdh: null,
        sbbm: null,
        cljd: null,
        sbmc: null,
        kssj: null,
        jssj: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.faultProgresss = selection.map(item => item.cljd)
      this.reportIds = selection.map(item => item.bxdh)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    // 班组翻译
    postFormat(row, column) {
      var actions = [];
      Object.keys(this.postOptions).some((key) => {
        if (this.postOptions[key].postCode == ('' + row.wxbz)) {
          actions.push(this.postOptions[key].postName);
          return true;
        }
      })
      return actions.join('');
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.$modal.alertError("该功能暂未开放");
      return
      this.reset();
      this.open = true;
      this.title = "添加设备故障维修";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getGzwx(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改设备故障维修";
      });
    },
    /*变更维修员*/
    handleJobSub(){
      let isUpdate=this.faultProgresss;
      if(isUpdate=='4'){
        this.$modal.alertWarning("此维修单已完成不能变更！");
        return;
      }
      this.jobSub.title = "变更维修人员";
      this.jobSub.open = true;
      setTimeout(() => {
        this.$refs.userPost.getList();
      }, 5);
    },
    /*撤单*/
    handleCancelReport(){
      console.log("撤单")
      let isUpdate=this.faultProgresss;
      console.log(isUpdate)
      if (isUpdate == [null] || isUpdate == '') {
        this.$modal.msgError("报修单号为空")
        return
      }
      if(isUpdate=='4'||isUpdate=='3'||isUpdate=='2'){
        this.$modal.alertWarning("此维修单已操作不能撤单！");
        return;
      }
      const reportId = this.reportIds;
      this.$modal.confirm('是否确认撤销设备故障维修单？').then(function() {
        return cancelDeviceFailureRepair(reportId);
      }).then(() => {
        this.getList();
        this.cancelReport.open = false;
        this.$modal.alertSuccess("撤单成功");
      }).catch(() => {});
    },

    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateGzwx(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addGzwx(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    handleClick() {
      if(this.$refs.userPost.zxrRadio==null){
        this.$modal.alertWarning("未设置主维修人！");
        return;
      }
      let fzMajorId=this.$refs.userPost.zxrRadio;
      if(this.$refs.userPost.ids.length>0){
        fzMajorId=this.$refs.userPost.ids;
        /*this.$modal.alertWarning("未指派维修人员！");
        return;*/
      }
      if(this.reportIds.length===0){
        this.$modal.alertWarning("未选中数据！");
        return;
      }
      let majorId=this.$refs.userPost.zxrRadio;
      let reportId=this.reportIds;
      this.$modal.confirm('确认变更维修人员？').then(function() {
        return updateJobSub(reportId,majorId,fzMajorId);
      }).then(() => {
        this.getList();
        this.jobSub.open = false;
        this.$modal.alertSuccess("变更成功");
      }).catch(() => {});

    },
    /*维修验证信息*/
    handleCheck(){
      const reportId = this.reportIds;
      console.log(reportId)
      if (reportId == [null] || reportId == '') {
        this.$modal.msgError("报修单号为空")
        return
      }
      getDeviceFailureCheckByReportId(reportId).then(response => {
        if(response.data==undefined){
          this.$modal.alertWarning("暂无验证信息！");
          return;
        }
        if(response.data.isFinish=='5'){
          //完成
          this.isWc=false;
          //驳回
          this.isBh=true;
          this.color='color:red';
          response.data.isFinish='驳回';
        }else if(response.data.isFinish=='4') {
          //完成
          this.isWc=true;
          //驳回
          this.isBh=false;
          response.data.isFinish='完成';
        }
        this.checkForm = response.data;
        this.check.title = "维修验证信息";
        this.check.open = true;
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除设备故障维修编号为"' + ids + '"的数据项？').then(function() {
        return delGzwx(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('device/gzwx/export', {
        ...this.queryParams
      }, `gzwx_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
